<?php
declare(strict_types=1);

namespace cms\system\api_controller;

use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\AutoController;
use HyperfExt\Auth\Contracts\AuthManagerInterface;
use HyperfExt\Jwt\Claims\Collection;
use HyperfExt\Jwt\Claims\Factory;
use HyperfExt\Jwt\Contracts\ManagerInterface;
use HyperfExt\Jwt\JwtFactory;
use HyperfExt\Jwt\Payload;
use HyperfExt\Jwt\PayloadFactory;

/**
 * Class TestController
 * @package cms\system\api_controller
 * @AutoController(prefix="api/system/test")
 */
class TestController extends AbstractController
{
    /**
     * @Inject()
     * @var ManagerInterface
     */
    protected ManagerInterface $jwtManager;
    public function t001()
    {
        // $jwt = new JwtFactory();
        // echo $jwt->make();
        $p = new PayloadFactory(new Factory(3600, 1800));
        $time = time();
        $jwt = $this->jwtManager->encode($p->make([
            'iss' => '',
            'sub' => '',
            'aud' => '',
            'exp' => $time + 3600,
            'nbf' => $time,
            'iat' => $time,
            'jti' => '112'
        ]));
        return $jwt;
    }

    public function t002()
    {
        // $authManage = make(AuthManagerInterface::class)->guard('wechat');
        // $authManage->login();
    }
}